<template>
  <div class="header-container">
    <div class="l-content">
        <el-button style="margin-right: 20px;"  @click="HandleMenu" icon="el-icon-menu" size="mini"></el-button>
        <el-breadcrumb separator="/">
            <el-breadcrumb-item v-for="item in tags" :key="item.path" :to="{ path: item.path }">{{item.label}}</el-breadcrumb-item>
        </el-breadcrumb>
    </div>
    <div class="r-content">
        <el-dropdown @command="HandleExit">
            <span class="el-dropdown-link">
                <img class="user" src="../assets/user.png" alt="">
            </span>
            <el-dropdown-menu slot="dropdown">
                <el-dropdown-item command="exit">退出</el-dropdown-item>
            </el-dropdown-menu>
        </el-dropdown>
    </div>

  </div>
</template>

<script>
import Cookie from "js-cookie"
import {mapState} from 'vuex'//vuex辅助函数
export default {
    name:'CommonHeader',
    data() {
        return {
            
        }
    },
    methods:{
        
        HandleMenu(){
            // console.log(this);
            this.$store.commit('collapseMenu')
        },
        HandleExit(command){
            if(command==="exit"){
                Cookie.remove('token')
                this.$router.push('/Login')
                this.$message.success("退出成功！")
            }
        }
    },
    computed:{
        ...mapState({
            tags:state=>{
                return state.tab.tabsList
            }
        })
    },
    mounted(){
        console.log(this.tags,'tags');
    }
}
</script>

<style lang="less" scoped>
   .header-container{
        padding: 0px 20px;
        background-color: #333;
        height: 60px;
        display: flex;
        justify-content: space-between;
        align-items: center;
   }
   .text{
    color:#fff;
    font-size: 14px;
    margin-left: 10px;
   }
   .r-content{
    .user{
        width: 40px;
        height: 40px;
        border-radius: 50%;
        margin-top:22px;
    }
   }
.l-content{
    display: flex;//
    align-items: center;//
    /deep/.el-breadcrumb__item{
        .el-breadcrumb__inner{
            &.is-link{
                font-weight: normal;
                color:#666;
            }
        }
        &:last-child{
            .el-breadcrumb__inner{
                color:#fff;
            }
            
        }
    }
}
</style>